package com.example.service.impl;

import com.example.mapper.StudentMapper;
import com.example.pojo.Student;
import com.example.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;
    @Transactional
    public void addStudent(Student student) {
        studentMapper.insertStudent(student);
    }
    @Transactional
    public void deleteStudent(int id) {
        studentMapper.deleteStudent(id);
    }
    @Transactional
    public void updateStudent(Student student) {
        studentMapper.updateStudent(student);
    }
    public Student getStudentById(int id) {
        return studentMapper.selectStudentById(id);
    }
    public List<Student> getAllStudents() {
        return studentMapper.selectAllStudents();
    }
}
